package 牛客小白月赛94;

import java.util.Scanner;

public class C小苯的数字合并 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long [] a = new long[n + 10];
		long[] sum = new long[n + 10];
		
		for(int i = 1; i <= n; i ++ ) {
			sum[i] = sum[i - 1];
			a[i] = sc.nextInt();
			sum[i] += a[i];
		}
		if(n == 1) {
			System.out.print(0);
			return ;
		}
		// 枚举剩下的是最后一个i是孤立的
		long ret = 0;
		for(int i = 1; i <= n; i ++ ) {
			long t = Math.max(Math.abs(sum[i - 1] - a[i]), Math.abs(sum[n] - sum[i] -a[i]));
			ret = Math.max(ret, t);
		}
		System.out.print(ret);
	}
}
